var BaseUtils = {
	getDefaultValue : function(value1, value2, value3) {
		if (value1 != null && value1.length > 0)
			return value1;
		else if (value2 != null && value2.length > 0)
			return value2;
		else if (value3 != null && value3.length > 0)
			return value3;

		return '';
	},

	getBrowser : function() {
		var browser = {};

		try {
			var ua = navigator.userAgent.toLowerCase();
			if (window.ActiveXObject)
				browser.ie = ua.match(/msie ([\d.]+)/)[1];
			else if (document.getBoxObjectFor)
				browser.firefox = ua.match(/firefox\/([\d.]+)/)[1];
			else if (window.MessageEvent && !document.getBoxObjectFor)
				browser.chrome = ua.match(/chrome\/([\d.]+)/)[1];
			else if (window.opera)
				browser.opera = ua.match(/opera.([\d.]+)/)[1];
			else if (window.openDatabase)
				browser.safari = ua.match(/version\/([\d.]+)/)[1];
		} catch (e) {

		}

		return browser;
	},

	getBrowserVersion : function(ie) {
		// 首先调用getBrowser()方法获取返回值
		// 再将返回值作为参数传到此方法中获取IE的版本
		var version = {};

		try {
			if (ie.indexOf('10.') != -1)
				version.ten = true;
			else if (ie.indexOf('9.') != -1)
				version.nine = true;
			else if (ie.indexOf('8.') != -1)
				version.eight = true;
			else if (ie.indexOf('7.') != -1)
				version.seven = true;
			else if (ie.indexOf('6.') != -1)
				version.six = true;
		} catch (e) {

		}

		return version;
	},

	stringToArray : function(string, split) {
		return string.split(',');
	},

	arrayToString : function(array, split) {
		if (array == null || array.length == 0)
			return '';
		
		var result = '';
		for (var i = 0; i < array.length; i++) {
			result += array[i];
			if (i < array.length - 1)
				result += split;
		}
		
		return result;
	},

	setReadonly : function(array) {
		if (array == null || array.lenth == 0)
			return;

		for (var i = 0; i < array.length; i++) {
			var obj = document.getElementById(array[i]);
			if (obj != null && obj != undefined) {
				obj.setAttribute('readOnly', true);
				obj.style.backgroundColor = '#dddddd';
			}
		}
	},
	
	isBlank : function(value) {
		return value == null || value.length == 0 || value == undefined;
	},

	isDouble : function(value) {
		if (BaseUtils.isBlank(value))
			return false;

		return /^[0-9]+.?[0-9]*$/.test(value);
	},

	replace : function(value, oldChar, newChar) {
		if (value == null || value.length == 0)
			return '';

		var reg = new RegExp(oldChar, 'g');
		return value.replace(reg, newChar);
	},
	
	parseBirthDayFromIdentityCardNo : function(value, split) {
		if (value == null || value.length < 14)
			return '';
		
		if (split == null || split.length == 0)
			split = '';
		
		var year = value.substring(6, 10);
		var month = value.substring(10, 12);
		var day = value.substring(12, 14);
		
		return year + split + month + split + day;
	},
	
	parseParam : function(param, key) {
		var result = '';
		if (param instanceof String || param instanceof Number || param instanceof Boolean) {
			result += '&' + key + '=' + encodeURIComponent(param);
		} else {
			$.each(param, function(i) {
				var k = (key == null) ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i);
				result += '&' + BaseUtils.parseParam(this, k);
			});
		}
		return result.substr(1);
	}
};